const puppeteer = require("puppeteer");

async function aliyun() {
  // ignoreDefaultArgs: ['--enable-automation']  去掉顶部puppeteer检测的提示
  const brower = await puppeteer.launch({
    headless: false,
    ignoreDefaultArgs: ["--enable-automation"],
  });
  const page = await brower.newPage();
  await page.setViewport({
    width: 2000,
    height: 800,
  });

  await page.goto("https://dun.163.com/trial/jigsaw");

  const divBtn = await page.waitForSelector("div.yidun_slider");
  const divBox = await page.waitForSelector("div.yidun_tips");

  // 拿到滑块当前的坐标
  const BtnInfo = await divBtn.boundingBox();
  console.log(BtnInfo);

  // 拿到滑块底部盒子的坐标
  const BoxInfo = await divBox.boundingBox();
  console.log(BoxInfo);
  // 鼠标移到滑块位置
  await page.mouse.move(BtnInfo.x, BtnInfo.y);
  // 按下鼠标
  await page.mouse.down();
  // 移动鼠标
  for (let k = 0; k < BoxInfo.width; k++) {
    await page.mouse.move(BtnInfo.x + k, BtnInfo.y);
  }
  // 松开鼠标
  await page.mouse.up();
}
    aliyun();

